<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <!--          <a-col :xl="6" :lg="7" :md="8" :sm="24">
                      <a-form-item label="评审表编号">
                        <a-input placeholder="请输入评审表编号" v-model="queryParam.code"></a-input>
                      </a-form-item>
                    </a-col>-->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="物料编码">
              <a-input placeholder="请输入物料编码" v-model="queryParam.packageCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="物料名称">
              <a-input placeholder="请输入物料名称" v-model="queryParam.packageName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="规格型号">
              <a-input placeholder="请输入规格型号" v-model="queryParam.noneSpec"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单编号">
              <a-input placeholder="请输入订单编号" v-model="queryParam.schedulingNumber"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="10" :lg="11" :md="12" :sm="24">
            <a-form-item label="制单日期">
              <j-date
                placeholder="请选择开始日期"
                class="query-group-cust"
                v-model="queryParam.createTime_begin"
              ></j-date>
              <span class="query-group-split-cust"></span>
              <j-date
                placeholder="请选择结束日期"
                class="query-group-cust"
                v-model="queryParam.createTime_end"
              ></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!--              <a @click="handleToggleSearch" style="margin-left: 8px">
                              {{ toggleSearchStatus ? '收起' : '展开' }}
                              <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
                            </a>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button v-if="activeKey=='cg'" @click="handleAdd" type="primary" icon="plus">添加</a-button>
      <a-button v-if="activeKey=='cg'" @click="addNew" type="primary" icon="plus">新增</a-button>
      <a-button v-if="activeKey=='cg'"@click="openButton('isShipment','0')" type="danger" ghost icon="close">发货关闭</a-button>
      <a-button @click="orderView" type="primary" icon="unordered-list">订单查看</a-button>
      <!--      <a-button type="primary" icon="download" @click="handleExportXls('发货商品通知单')">导出</a-button>
            <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
              <a-button type="primary" icon="import">导入</a-button>
            </a-upload>-->
      <!-- 高级查询区域 -->
      <!--      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
            <a-dropdown v-if="selectedRowKeys.length > 0">
              <a-menu slot="overlay">
                <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
              </a-menu>
              <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
            </a-dropdown>-->
    </div>

    <!-- table区域-begin -->

        <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
            <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
            <a style="margin-left: 24px" @click="onClearSelected">清空</a>

          <span style="float:right;">
          <a-popover title="自定义列" trigger="click" placement="leftBottom">
            <template slot="content">
              <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
                <a-row style="width: 400px">
                  <template v-for="(item,index) in defColumns">
                    <template v-if="item.key!=='rowIndex'&& item.dataIndex!=='action'">
                        <a-col :span="12"><a-checkbox :value="item.dataIndex"><j-ellipsis :value="item.title" :length="10"></j-ellipsis></a-checkbox></a-col>
                    </template>
                  </template>
                </a-row>
              </a-checkbox-group>
            </template>
            <a><a-icon type="setting" />设置</a >
          </a-popover>
        </span>
          </div>
    <a-tabs v-model="activeKey" @change="handleChangeTab">
      <a-tab-pane key="cg" tab="未生成">
        <div>
          <a-table
            ref="procTable"
            size="middle"
            bordered
            rowKey="detailId"
            class="j-table-force-nowrap1"
            :scroll="{ x: true }"
            :columns="table1.columns"
            :dataSource="table1.dataSource"
            :pagination="table1.ipagination"
            :loading="table1.loading"
            @change="handleTableChange1"
            :rowSelection="{ selectedRowKeys: table1.selectedRowKeys, onChange: onSelectChangeTab1 }"
          >

          </a-table>
        </div>
      </a-tab-pane>


      <a-tab-pane key="notGenerated" tab="暂存中">
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="detailId"
            class="j-table-force-nowrap1"
            :scroll="{x:true}"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            :rowSelection="{type:'radio',selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
            @change="handleTableChange">

            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>

            <span slot="action" slot-scope="text, record">
          <a v-if="record.status < 0" @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />

         <act-apply-btn
           @success="handleChangeTab"
           :data-id="record.id"
           :serviceName="serviceName"
           :variables="record"
         ></act-apply-btn>
          <a-divider type="vertical" />

          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

          </a-table>
        </div>
      </a-tab-pane>

      <a-tab-pane key="needEdit" tab="需修改">
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="detailId"
            class="j-table-force-nowrap1"
            :scroll="{x:true}"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            :rowSelection="{type:'radio',selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
            @change="handleTableChange">

            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>

            <span slot="action" slot-scope="text, record">
          <a v-if="record.status < 0" @click="handleEdit(record)">编辑</a>

             <a-divider v-if="record.status < 0"  type="vertical" />
                <act-apply-btn
                  v-show="record.actStatus == '撤回'"
                  @success="handleChangeTab"
                  :data-id="record.id"
                  :serviceName="serviceName"
                  :variables="record"
                ></act-apply-btn>
              <a-popconfirm  v-if="record.actStatus != '撤回'" title="确定取消申请吗?" @confirm="() => handleStop(record)">
               <a href="javascript:;">取消申请</a>
              </a-popconfirm>
              <a-divider v-if="record.actStatus != '撤回'" type="vertical" />
              <act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>
             <a-divider type="vertical" />
               <a @click="handleDetail(record)">详情</a>
        </span>

          </a-table>
        </div>
      </a-tab-pane>

      <a-tab-pane key="approving" tab="审核中">
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="detailId"
            class="j-table-force-nowrap1"
            :scroll="{x:true}"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            :rowSelection="{type:'radio',selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
            @change="handleTableChange">

            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>

            <span slot="action" slot-scope="text, record">
          <act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>
          <a-divider type="vertical" />
         <a @click="handleDetail(record)">详情</a>
           <a-divider v-if="record.actStatus != '撤回'" type="vertical" />
              <a-popconfirm  v-if="record.actStatus != '撤回'" title="确定取消申请吗?" @confirm="() => handleStop(record)">
               <a href="javascript:;">取消申请</a>
              </a-popconfirm>
        </span>

          </a-table>
        </div>
      </a-tab-pane>

      <a-tab-pane key="approved" tab="已审批">
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="detailId"
            class="j-table-force-nowrap1"
            :scroll="{x:true}"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            :rowSelection="{type:'radio',selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
            @change="handleTableChange">

            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>

            <span slot="action" slot-scope="text, record">
            <act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>
          <a-divider type="vertical" />
              <a-popconfirm  v-if="record.actStatus != '撤回'" title="确定取消申请吗?" @confirm="() => handleOverStop(record)">
               <a href="javascript:;">取消申请</a>
              </a-popconfirm>
          <a-divider type="vertical" />
          <a @click="handleDetail(record)">详情</a>
        </span>

          </a-table>
        </div>
      </a-tab-pane>
    </a-tabs>
    <crm-shipment-goods-modal :salesType="'1'" ref="modalForm" @ok="modalFormOk"/>
    <buss-tra-orders-modal ref="orderModal" @ok=""></buss-tra-orders-modal>
  </a-card>
</template>

<script>

import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import CrmShipmentGoodsModal from './modules/CrmShipmentGoodsModal'
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
import '@/assets/less/TableExpand.less'
import { deleteAction, getAction, postAction } from '@api/manage'
import {filterObj} from "@/utils/util";
import {stopProcess} from "@views/flowable/api/process";
import ActApplyBtn from '@views/flowable/components/ActApplyBtn.vue'
import ActCancelBtn from '@views/flowable/components/ActCancelBtn.vue'
import ActHandleBtn from '@views/flowable/components/ActHandleBtn.vue'
import ActHistoricDetailBtn from '@views/flowable/components/ActHistoricDetailBtn.vue'
import BussTraOrdersModal from '@views/crm/tsldomestic/modules/BussTraOrdersModal.vue'
export default {
  name: "CrmShipmentGoodsList",
  mixins:[JeecgListMixin],
  components: {
    BussTraOrdersModal,
    CrmShipmentGoodsModal,
    ActApplyBtn,
    ActCancelBtn,
    ActHandleBtn,
    ActHistoricDetailBtn,
  },
  data () {
    return {
      description: '发货商品通知单管理页面',
      serviceName: 'shipmentGoodsService',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key:'rowIndex',
          width:60,
          align:"center",
          customRender:function (t,r,index) {
            return parseInt(index)+1;
          }
        },
        {
          title:'出库单号',
          align:"center",
          dataIndex: 'shipmentCode'
        },
        {
          title:'订单编号',
          align:"center",
          dataIndex: 'schedulingNumber'
        },
        {
          title:'销售类型',
          align:"center",
          dataIndex: 'salesType_dictText'
        },
        {
          title:'业务类型',
          align:"center",
          dataIndex: 'contractBusinessType_dictText'
        },
        {
          title:'客户名称',
          align:"center",
          dataIndex: 'customerName'
        },
        {
          title:'地址',
          align:"center",
          dataIndex: 'address'
        },
        {
          title:'业务员',
          align:"center",
          dataIndex: 'salesman_dictText'
        },
        {
          title:'客户物料编码',
          align:"center",
          dataIndex: 'customCode'
        },
        {
          title:'物料编码',
          align:"center",
          dataIndex: 'packageCode'
        },
        {
          title:'物料名称',
          align:"center",
          dataIndex: 'packageName'
        },
        {
          title:'规格型号',
          align:"center",
          dataIndex: 'noneSpec'
        },
        {
          title:'主计量单位',
          align:"center",
          dataIndex: 'meUnit_dictText'
        },
        {
          title:'发货数量',
          align:"center",
          dataIndex: 'mainQuantity'
        },
        {
          title:'实发数量',
          align:"center",
          dataIndex: 'lssuedQuantity'
        },
        {
          title:'开票人',
          align:"center",
          dataIndex: 'drawer_dictText'
        },
        {
          title: '制单人',
          align: 'center',
          dataIndex: 'createBy_dictText',
        },
        {
          title: '制单部门',
          align: 'center',
          dataIndex: 'sysOrgCode_dictText',
        },
        {
          title: '制单时间',
          align: 'center',
          dataIndex: 'createTime',
          sorter: (a, b) => a.createTime.localeCompare(b.createTime, 'en'),
        },

        {
          title: '操作',
          dataIndex: 'action',
          align:"center",
          fixed:"right",
          width:147,
          scopedSlots: { customRender: 'action' },
        }
      ],
      settingColumns: [],
      defColumns: [
        {
          title: '#',
          dataIndex: '',
          key:'rowIndex',
          width:60,
          align:"center",
          customRender:function (t,r,index) {
            return parseInt(index)+1;
          }
        },
        {
          title:'出库单号',
          align:"center",
          dataIndex: 'shipmentCode'
        },
        {
          title:'订单编号',
          align:"center",
          dataIndex: 'schedulingNumber'
        },
        {
          title:'销售类型',
          align:"center",
          dataIndex: 'salesType_dictText'
        },
        {
          title:'业务类型',
          align:"center",
          dataIndex: 'contractBusinessType_dictText'
        },
        {
          title:'客户名称',
          align:"center",
          dataIndex: 'customerName'
        },
        {
          title:'地址',
          align:"center",
          dataIndex: 'address'
        },
        {
          title:'业务员',
          align:"center",
          dataIndex: 'salesman_dictText'
        },
        {
          title:'客户物料编码',
          align:"center",
          dataIndex: 'customCode'
        },
        {
          title:'物料编码',
          align:"center",
          dataIndex: 'packageCode'
        },
        {
          title:'物料名称',
          align:"center",
          dataIndex: 'packageName'
        },
        {
          title:'规格型号',
          align:"center",
          dataIndex: 'noneSpec'
        },
        {
          title:'主计量单位',
          align:"center",
          dataIndex: 'meUnit_dictText'
        },
        {
          title:'发货数量',
          align:"center",
          dataIndex: 'mainQuantity'
        },
        {
          title:'实发数量',
          align:"center",
          dataIndex: 'lssuedQuantity'
        },
        {
          title:'开票人',
          align:"center",
          dataIndex: 'drawer_dictText'
        },
        {
          title: '制单人',
          align: 'center',
          dataIndex: 'createBy_dictText',
        },
        {
          title: '制单部门',
          align: 'center',
          dataIndex: 'sysOrgCode_dictText',
        },
        {
          title: '制单时间',
          align: 'center',
          dataIndex: 'createTime',
          sorter: (a, b) => a.createTime.localeCompare(b.createTime, 'en'),
        },

        {
          title: '操作',
          dataIndex: 'action',
          align:"center",
          fixed:"right",
          width:147,
          scopedSlots: { customRender: 'action' },
        }
      ],
      table1: {
        selectedRowKeys: [],
        selectionRows: [],
        loading: false,
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1
            },
          },
          {
            title: '订单编号',
            align: 'center',
            dataIndex: 'schedulingNumber',
          },
          {
            title: '订单类型',
            align: 'center',
            dataIndex: 'documentType_dictText',
          },
          {
            title: '销售类型',
            align: 'center',
            dataIndex: 'salesType_dictText',
          },
          {
            title: '业务类型',
            align: 'center',
            dataIndex: 'contractBusinessType_dictText',
          },
          {
            title: '客户物料编码',
            align: 'center',
            dataIndex: 'customCode',
          },
          {
            title: '物料编码',
            align: 'center',
            dataIndex: 'packageCode',
          },
          {
            title: '物料名称',
            align: 'center',
            dataIndex: 'packageName',
          },
          {
            title: '规格型号',
            align: 'center',
            dataIndex: 'noneSpec',
          },
          {
            title: '主计量单位',
            align: 'center',
            dataIndex: 'meUnit_dictText',
          },
          {
            title: '订单数量',
            align: 'center',
            dataIndex: 'mainQuantity',
          },
          {
            title: '库存',
            align: 'center',
            dataIndex: 'stockQuantity',
          },
          {
            title: '客户名称',
            align: 'center',
            dataIndex: 'customerName',
          },
          {
            title: '制单人',
            align: 'center',
            dataIndex: 'createBy_dictText',
          },
          {
            title: '制单部门',
            align: 'center',
            dataIndex: 'sysOrgCode_dictText',
          },
          {
            title: '制单日期',
            align: 'center',
            dataIndex: 'createTime',
            sorter: (a, b) => a.createTime.localeCompare(b.createTime, 'en'),
          },
        ],
        dataSource: [],
        isorter: {
          column: 'createTime',
          order: 'desc',
        },
        ipagination: {
          current: 1,
          pageSize: 20,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0,
        },
      },
      url: {
        list: "/shipment/crmShipmentGoods/list",
        delete: "/shipment/crmShipmentGoods/delete",
        deleteBatch: "/shipment/crmShipmentGoods/deleteBatch",
        exportXlsUrl: "/shipment/crmShipmentGoods/exportXls",
        importExcelUrl: "shipment/crmShipmentGoods/importExcel",
        noOrderGenerated:"/shipment/crmShipmentGoods/noOrderGenerated",
        shipmentClose: '/review/crmTradeOrder/shipmentClose',
        queryBySchedulingNumber:'/review/crmTradeOrder/queryBySchedulingNumber',
      },
      activeKey:'cg',
      dictOptions:{},
      superFieldList:[],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    handleOverStop(row) {
      const params = {
        instanceId: row.processInstanceId,
      }
      console.log("111111111111111111",row)
      getAction("/shipment/crmShipmentGoods/queryOutboundOrder",{documentNumber:row.shipmentCode}).then((res) =>{
        if(res.success){
          if (res.result.length>0){
            stopProcess(params).then((b) => {
              this.$message.success(b.message)
              let ids=res.result.map(item=>item.id).join(',')
              deleteAction("/wms/outbound/outbound-order/deleteBatch",{ids:ids})
              this.handleChangeTab()
            })
          }else {
            return this.$message.warning("请先撤回出库单")
          }
        }
      })

    },
    orderView(){
      let rows = []
      switch (this.activeKey) {
        case 'cg':
          rows = this.table1.selectionRows
          break
        case 'notGenerated':
          rows = this.selectionRows
          break
        case 'needEdit':
          rows =this.needEditTable.selectedRows
          break
        case 'approving':
          rows =this.approvingTable.selectedRows
          break
        case 'approved':
          rows =this.approvedTable.selectedRows
          break
        default:
          break
      }
      console.log("rowssssss",rows)
      if (rows.length != 1) {
        this.$message.warn('请选择一条记录！')
        return
      }
      getAction(this.url.queryBySchedulingNumber,{schedulingNumber:rows[0].schedulingNumber}).then((res) =>{
        if(res.code!=200){
          this.$message.warn('未查询到对应订单！')
          return
        }else{
          this.$refs.orderModal.edit(res.result);
          this.$refs.orderModal.title = "详情";
          this.$refs.orderModal.disableSubmit = true;
        }
      })
    },
    openButton(record,code){
      if (this.table1.selectionRows.length == 0) {
        this.$message.warn('请选择订单！')
        return
      }
      const rows = this.table1.selectionRows[0]
      // rows[record] = code
      getAction(this.url.shipmentClose, {id:rows.id}).then((res)=>{
        if(res.code==200){
          this.$message.success(res.message);
          // that.$emit('ok');
        }else{
          this.$message.warning(res.message);
        }
      }).finally(() => {
        this.handleChangeTab()
      })

    },
    handleStop(row) {
      const params = {
        instanceId: row.processInstanceId,
      }
      stopProcess(params).then((res) => {
        this.$message.success(res.message)
        this.handleChangeTab()
      })
    },
    addNew(){
      this.$refs.modalForm.addNew();
      this.$refs.modalForm.title = "新增";
      this.$refs.modalForm.disableSubmit = false;
    },
    handleAdd(){
      if(this.table1.selectionRows.length<=0) {
        this.$message.warning('请选择一条记录！');
        return;
      }
      const names = this.table1.selectionRows.map(row => row.customerName);
      if(new Set(names).size > 1){
        this.$message.warning("只能选择同一个客户的物料")
        return
      }
      this.$refs.modalForm.add(this.table1.selectionRows);
      this.$refs.modalForm.title = "新增";
      this.$refs.modalForm.disableSubmit = false;

    },
    getQueryParams() {
      //获取查询条件
      let sqp = {}
      if (this.superQueryParams) {
        sqp['superQueryParams'] = encodeURI(this.superQueryParams)
        sqp['superQueryMatchType'] = this.superQueryMatchType
      }
      var param = Object.assign(sqp, this.queryParam, this.isorter, this.filters);
      // param.field = this.getQueryField();
      param.pageNo = this.ipagination.current;
      param.pageSize = this.ipagination.pageSize;
      return filterObj(param);
    },
    modalFormOk() {
      // 新增/修改 成功时，重载列表
      switch (this.activeKey) {
        case 'cg':
          this.loadData(0,999)
          break
        case 'notGenerated':
          this.loadData(0,-2)
          break
        case 'needEdit':
          this.loadData(0,-1)
          break
        case 'approving':
          this.loadData(0,0)
          break
        case 'approved':
          this.loadData(0,999)
          break
        default:
          break
      }
      //清空列表选中
      this.onClearSelected()
    },
    onClearSelected() {
      this.table1.selectedRowKeys = [];
      this.table1.selectionRows = [];
    },
    onSelectChangeTab1(selectedRowKeys, selectionRows) {
      this.table1.selectedRowKeys = selectedRowKeys
      this.table1.selectionRows = selectionRows
    },
    handleTableChange1(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      //TODO 筛选
      console.log(pagination)
      if (Object.keys(sorter).length > 0) {
        this.table1.isorter.column = sorter.field;
        this.table1.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
      }
      this.table1.ipagination = pagination;
      this.loadData(0,999);
    },
    handleTableChange(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      //TODO 筛选
      console.log(pagination)
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field;
        this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
      }
      this.ipagination = pagination;
      switch (this.activeKey) {
        case 'notGenerated':
          this.loadData(0,-2)
          break
        case 'needEdit':
          this.loadData(0,-1)
          break
        case 'approving':
          this.loadData(0,0)
          break
        case 'approved':
          this.loadData(0,999)
          break
        default:
          break
      }
    },
    loadData(arg,status) {
      if (!this.url.list) {
        this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      var params = this.getQueryParams();//查询条件
      params.status = status
      params.salesType = 2

      if(this.activeKey=='cg'){
        this.table1.loading = true
        getAction(this.url.noOrderGenerated, params).then((res) => {
          if (res.success) {
            //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            this.table1.dataSource = res.result.records || res.result;
            this.dataSourceBack=this.dataSource
            if (res.result.total) {
              this.ipagination.total = res.result.total;
            } else {
              this.ipagination.total = 0;
            }
            //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          } else {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.table1.loading = false
        })
      }else {
        this.loading = true;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            this.dataSource = res.result.records || res.result;
            this.dataSourceBack=this.dataSource
            if (res.result.total) {
              this.ipagination.total = res.result.total;
            } else {
              this.ipagination.total = 0;
            }
            //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          } else {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.loading = false
        })
      }
    },
    searchReset(noClearQueryParam) {
      if (noClearQueryParam === false) {
        //不清参数
      } else {
        this.queryParam = {};
      }
      this.handleChangeTab();
    },
    searchQuery() {
      if(typeof this.beforeSearch === 'function'){
        let isreturn = this.beforeSearch()
        if(!isreturn){
          return;
        }
      }
      this.handleChangeTab();
      // 点击查询清空列表选中行
      // https://gitee.com/jeecg/jeecg-boot/issues/I4KTU1
    },
    handleChangeTab() {
      switch (this.activeKey) {
        case 'cg':
          this.loadData(1,999)
          break
        case 'notGenerated':
          this.loadData(1,-2)
          break
        case 'needEdit':
          this.loadData(1,-1)
          break
        case 'approving':
          this.loadData(1,0)
          break
        case 'approved':
          this.loadData(1,999)
          break
        default:
          break
      }
    },
    initDictConfig(){
    },
    getSuperFieldList(){
      let fieldList=[];
      fieldList.push({type:'string',value:'shipmentCode',text:'出库单号',dictCode:''})
      fieldList.push({type:'string',value:'customerName',text:'客户名称',dictCode:''})
      fieldList.push({type:'string',value:'address',text:'收货地址',dictCode:''})
      fieldList.push({type:'string',value:'flowFlag',text:'审批流程',dictCode:'shipment_flow_type'})
      fieldList.push({type:'string',value:'priceType',text:'单价类型',dictCode:'unit_price_type'})
      fieldList.push({type:'string',value:'currency',text:'币种',dictCode:'currency'})
      fieldList.push({type:'sel_user',value:'drawer',text:'开票人'})
      fieldList.push({type:'date',value:'shipmentDate',text:'发货日期'})
      fieldList.push({type:'BigDecimal',value:'otherAmounts',text:'其他金额',dictCode:''})
      fieldList.push({type:'BigDecimal',value:'orderFees',text:'客户订单费用',dictCode:''})
      fieldList.push({type:'BigDecimal',value:'totalAmount',text:'总金额',dictCode:''})
      fieldList.push({type:'BigDecimal',value:'totalTonnage',text:'总吨数',dictCode:''})
      fieldList.push({type:'string',value:'billLading',text:'提单号',dictCode:''})
      fieldList.push({type:'string',value:'vehicleNumber',text:'运输车号',dictCode:''})
      fieldList.push({type:'string',value:'driverName',text:'驾驶员姓名',dictCode:''})
      fieldList.push({type:'Text',value:'notes',text:'备注',dictCode:''})
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>